package com.panorama.visitor.test_nodes;

import com.panorama.visitor.VisitableNode;
import com.panorama.visitor.Visitor;
import com.panorama.visitor.annotation.Copy;

public abstract class AbstractNode implements VisitableNode, TypeChecked {
	
	@Copy
	private String name = "";
	
	@Copy
	private boolean bool = false;
	
	public AbstractNode() {
		
	}
	
	public AbstractNode(String name) {
		this.name = name;
	}

	public <R> R accept(Visitor<R> visitor) {
		visitor = visitor.enter(this);
		
		if(visitor.override(this)) {
			return visitor.overrideValue(this);
		}
		
		visitor.visit(this);
		visitor.visitChildren(this);
		
		return visitor.leave(this);
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public String toString() {
		return getClass().getSimpleName() + "(" + name + ")";
	}

	/**
	 * @return the bool
	 */
	public boolean isBool() {
		return bool;
	}

	/**
	 * @param bool the bool to set
	 */
	public void setBool(boolean bool) {
		this.bool = bool;
	}
	
	@Override
	public void typeCheck() {
		// Do nothing by default
	}

}
